<?php

class ActionsBase {

  public function parameters($parameters_array){
    /*
     *  $module->parameters(array(
          "get" => $this->getParameters,
          "post" => $this->postParameters,
          "url" => $this->urlParameters,
          "num" => $this->urlParametersNum,
          "all" => $this->parameters,
          "module" => $this->module_name,
          "action" => $this->action_name
          ));
     */
    $this->petParameters  = isset($parameters_array['get'])   ?$parameters_array['get']   :array();
    $this->postParameters = isset($parameters_array['post'])  ?$parameters_array['post']  :array();
    $this->urlParameters  = isset($parameters_array['url'])   ?$parameters_array['url']   :array();
    $this->numParameters  = isset($parameters_array['num'])   ?$parameters_array['num']   :array();
    $this->parameters     = isset($parameters_array['all'])   ?$parameters_array['all']   :array();
    $this->moduleName     = isset($parameters_array['module'])?$parameters_array['module']:array();
    $this->actionName     = isset($parameters_array['action'])?$parameters_array['action']:array();
  }

  public function param($name){
    if(is_int($name) && isset($this->numParameters[$name]))  return $this->numParameters[$name];
    return isset($this->parameters[$name])?$this->parameters[$name]:null;
  }
  
  public function redirect($url){
    return $this->controller->redirect($url);
  }
  
  public function authenticate(){
    $this->user->forceLogin($_SERVER['REQUEST_URI']);
  }
}